using System;
using System.Collections.Generic;
using System.Linq;
namespace BuddhistSchools.DTO.Models
{
    public partial class Pagoda
    {
        public List<Pagoda> GetListPagoda(int ProvinceID,string key)
        {
            dbBuddhistSchoolsContext db = new dbBuddhistSchoolsContext();
            return db.Pagodas.Where(p=>p.ProvinceID==ProvinceID && p.Name.Contains(key)).OrderBy(p=>p.Name).ToList();
        }
        public List<Pagoda> GetListPagoda( string key)
        {
            dbBuddhistSchoolsContext db = new dbBuddhistSchoolsContext();
            return db.Pagodas.Where(p => p.Name.Contains(key)).OrderBy(p => p.Name).ToList();
        }
        public bool Them(Pagoda pagoda)
        {
            dbBuddhistSchoolsContext db = new dbBuddhistSchoolsContext();
            db.Pagodas.Add(pagoda);
            return db.SaveChanges() > 0;
        }
        public bool Sua(Pagoda pagoda)
        {
            dbBuddhistSchoolsContext db = new dbBuddhistSchoolsContext();
            var pro = db.Pagodas.Find(pagoda.Id);
            pro.Name = pagoda.Name;
            return db.SaveChanges() > 0;
        }
    }
}
